package Simulation;

import fxana.FxRawDataSet;
import fxana.RawDataCell;

public class ConditionLSM extends Condition {
	/* This construct is for seed */
	public ConditionLSM(){
		super();
	}
	public ConditionLSM(FxRawDataSet ds, RawDataCell today,
			EvaluatorParaFlag flag) {
		super(ds, today, flag);
	}

	@Override
	protected void PreProcess(FxRawDataSet ds, RawDataCell today,
			EvaluatorParaFlag flag) {
	
		if(flag.IsLFlagSet()&&flag.GetLFlagIterator().hasNext()){
			super.LossCutValue=flag.GetLFlagIterator().next()/10.0;
		}
	}

	@Override
	protected Condition GetNew(FxRawDataSet ds, RawDataCell today,
			EvaluatorParaFlag flag) {
		return new ConditionLSM(ds,today,flag);
	}

	@Override
	protected RawDataCell GetEstimatedValue(FxRawDataSet ds, RawDataCell today,
			EvaluatorParaFlag flag) {
		Integer numberofday=25;
		
		if(flag.IsMFlagSet()&&flag.GetMFlagIterator().hasNext()){
			numberofday=flag.GetMFlagIterator().next();
		}
		
		RawDataCell est=ds.GetLSMDataByDate(today.GetRecDate(), numberofday);
		return est;
	}
	@Override
	protected void UpdateLossCutValue(FxRawDataSet ds, RawDataCell today,
			EvaluatorParaFlag flag) {
		return;
	}
}
